Enable and Disable the Login and Play buttons on Character Summary view dependent on EFT's running state. #285
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updated the CharacterSummaryViewModel to expose an additional property _canLaunch (with an Observable generated instance) which is set to either true or false (defaults to true) depending on the state of _tarkovClientService.RunningStateChanged.
An event handler is attached to listen for RunningStateChanged events, if the state is either Starting or Running _canLaunch is set to false, the other states (NotRunning and StoppedUnexpectedly) set this to true.
The CharacterSummaryView.axaml's command button (Login or Play) has the property IsEnabled bound to this new property - in doing this all buttons are enabled or disabled when EFT is started/stopped. This property is changed on the UI thread with the use of Dispatcher.UIThread.Invoke().
The upshot of this change is that the UI now behaves as such:
Not logged in, Tarkov not running, all buttons enabled:
Login dialog disables the login button for the selected profile (as expected for a button with a bound command):
Successful login, Tarkov now running (or starting up), all buttons are disabled:
Exited from Tarkov, all buttons are enabled.
Saved profiles work in much the same way - but without the login dialog of course.
Saved profile (remember me ticked during login), Tarkov not running all buttons available.
Saved profile (remember me ticked during login), Tarkov running all buttons disabled.
Saved profile (remember me ticked during login), Tarkov exited all buttons available again.
Note
Have added comments in the CharacterSummaryViewModel constructor regarding future implementation of IActivatableViewModel from Avalonia.ReactiveUI - however it would require changes to the code behind the axaml. It may be worth looking into this as part of a larger refactor at a later date.